import Vue from "vue";
//创建路由组件
import VueRouter from "vue-router";
import Home  from '../views/home.vue';
import User  from '../views/user.vue';
import  Main from '../views/main.vue';
import  Mall from '../views/mall.vue';
import  pageOne from '../views/pageOne.vue';
import  pageTwo from '../views/pageTwo.vue';
import  login from '../views/login.vue'
Vue.use(VueRouter)   

//将路由与组件进行映射

const  routes = [
    //主路由
    {
    path:'/',
    component:Main,
    name:"Main",
    redirect:'/home', //重定向
    children:[
        {path:'home',name:'home', component:Home },//首页
        {path:'user',name:'user',component:User},//用户管理
        {path:'mall',name:'mall',component:Mall},//商品管理
        {path:'page1',name:'page1',component:pageOne},//页面1
        {path:'page2',name:'page2',component:pageTwo},//页面2

    ]

},
{
    path:"/login",
    name:'login',
    component:login
}
    
]

//创建路由实例
const router=new VueRouter({
    routes
})
//将router实例暴露出去
export default router

